def solution():
    i = 0
    while i == 0:
        try:
            str = input()
            l = list(str)
            l.sort()
            l.reverse()
            smax = "".join(l)
            print(smax)
            l.reverse()
            smin = "".join(l)
            smin = smin.replace('0', '')
            print(smin)
        except:
            break

solution()